(ns clj.ex4)

(defn ando
  ([] true)
  ([x] (if (nil? x) true x))
  ([x y & next]
    (println " and " x "-" y)
      (if x (ando y next) false)))


(defn defvar [[name# value#]]
  (println "defing " name# " : " value#)
  (def name# value#))

 (defmacro for-ex [for-ini for-comp for-next & body]
    `(let [init# (partition 2 ~for-ini)] 
       (doall (map defvar init#))
       (if (reduce ando ~for-comp) (println "reduce true") (println "reduce false"))
       ))
 
; (def f (for-ex [(def i 0) (< i 10) (def i (inc i))] 
;                 #(println "line here " i) ))
 
 ;(for-ex [i 0 j 1 k 2] [(< i 10) (< j 12)] [(inc i) (inc j)] #(do-somthing))
 
 
 
(defn test4 [& args]
  (println "Playing in test4 - macro FOR " args)
  
  ;(for-ex '[i 0 j 1 k 2] '[(< i 10) (< j 12) (< k 5)] '[(inc i) (inc j)] #(println "for-do"))
  
  
  (println (reduce ando [(< 1 10) (> 2 10)]))
  
  ;(macroexpand-1 'f)
;(def i 0)
;(println "i:" (inc i))

;(def v [(def i 20) (< i 10)])
;(defn vf [prms]
;  (let [[v1 v2] prms]
;  (println "v1 " v1)
;  (println "v2 " v2)
;  ))
;
;(vf v)
  
  "test1 finished")
